<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>这是哪</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
       html,body{
         margin: 0;
         padding: 0;
         height: 100%;
       }
        label {
            margin: 10px;
            font-size: 24px;
        }

        ul {
            margin-bottom: 10px;
        }

        ul li {
            margin: 5px 10px;
            padding: 5px;
            color: #000;
            word-wrap: break-word;
        }
        .nav{
          margin-top: 10px;
          /*background-color: red;*/
            /*margin-left: 10px;*/
        }
        #broadcast{
          margin-top: 60px;
          z-index: -99999;
        }
        /*.nav div{

          margin: auto;
          float: left;
          margin-right: 20%;
        }*/
        .myproject{
          /*background-color: #987;*/
          float: left;
          margin-left: 9%;

        }
        .mypower{
          /*background-color: #678;*/
          float: left;
          margin-left: 15%;
        }
        .myworks{
          /*background-color: #876;*/
          float: left;
          margin-left: 15%;
        }
        .hot{
          /*font-size: 1.1em;*/
          background-color:#FFFFFF ;
          border-top: 1px solid #fff7ff;
          border-bottom: 10px solid #f0f0f0;
          clear:both;
          color:  #1296db;
          /*float: right;*/
          /*background-color: #87cefa;*/
        }
        .hot img{
          height: 20px;
          width: 20px;
          margin: 0 3px 0;
        }



       .list{
         background-color: #ecf5ff;
         /*#87cefa;#fcfcfc*/

       }
        .left{
          margin-left: 5px;
          padding-top: 5px;
          /*border-bottom: 2px solid #fff7ff*/
        }
        .company_logo{
          width: 30px;
          height: 30px;
          float: left;
        }
        .project_company{
          /*background-color: red;*/
        }
      .hot_tags{
        /*background-color: blue;*/
        float: right;
        margin-top: -20px;
      }
    .templatebox{
      /*background-color: red;*/
      border-bottom: 5px solid #CCCCCC;
    }
    .project_detail .btn .btn-info{
    background-color: red;
    }
    /*style="float:right;margin-top:-25px;font-size:1.5em;"*/
    button{
      /*background-color: red;*/
    }
    /*.list .btn{
      background-color: #BCEE68;
    }*/
.header{
  background-color: #1296db;
  text-align: center;
  /*margin-top: 15px;*/
  padding-top: 25px;
  padding-bottom: 10px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  /*height: 45px;*/

}
h3 {
    color: white;
    font-weight: lighter;
}
/*.box{
  background-color: red;
}*/
.sa{
  background-color: #BCEE68;float:right;margin-top:-25px;font-size:1.5em;
}
.send{
  background-color:#CD4F39;float:right;margin-top:-25px;font-size:1.5em;
}
    </style>
</head>

<body>
  <div class="header">
    <h3>首页</h3>
  </div>
   <div id="broadcast">

   </div>
<div class="nav">
  <div class="myproject" onclick="openPage('myproject','firstpage/first1.html')">
      <img src="../image/project.png" alt="1"><br>

    <!-- <a href="myproject.html"></a>  -->
     <span>我的项目</span>
  </div>
  <div class="mypower" onclick="openPage('mypower','firstpage/first21.html')">
      <img src="../image/power.png" alt="2"><br>
      <span>能力导航</span>
  </div>
  <div class="myworks" onclick="openPage('myworks','firstpage/first3.html')">
      <img src="../image/works.png" alt="3"><br>
      <span>我的作品</span>
  </div>
</div>
<div class="box">
  <div class="hot">

    <img src="../image/hot.png" alt="4">
    热门项目
  </div>
</div>
<div class="hotproject">

</div>



    <div id='sys-info'></div>
</body>
<script type="text/javascript" src="../script/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/main.js"></script>

<script type="text/javascript">
// fixedOn:api.UIScrollPicture;
// var broadcast =document.getElementById('broadcast');

    apiready = function() {
      // var opanPage =openPage();
      var broadcast =$("#broadcast")[0];
      $("#broadcast").css("height",api.winHeight / 4);

      var UIScrollPicture = api.require('UIScrollPicture');
      UIScrollPicture.open({
        rect: {
          // x : broadcast.offsetLeft,
          // y : broadcast.offsetTop,
          // w : broadcast.offsetWidth,
          // h : broadcast.offsetHeight
             x: 0,
            y: $api.offset(broadcast).t,
            w: api.winWidth,
            h: api.winHeight / 4
        },
        data: {
            paths: [
                'widget:/image/5.jpg',
                'widget:/image/2.jpg',
                'widget:/image/3.jpg',
                'widget:/image/4.jpg'
            ],
            captions: ['1', '2', '3', '4']
        },
        styles: {
            caption: {
                height: 0,
                color: '#000000',
                size: 15,
                bgColor: '#ffffff',
                position: 'top'
            },
            indicator: {
               dot:{
                 w:10,
                 h:10,
                 r:5,
                 margin:20
              },
                align: 'center',
                color: '#FFFFFF',
                activeColor: '#DA70D6'
            }
        },

        contentMode: 'scaleToFill',
        interval: 3,
        fixedOn: api.frameName,
        loop: true,
        fixed: false
      }, function(ret, err) {
        if (ret) {
            //alert(JSON.stringify(ret));
        } else {
            //alert(JSON.stringify(err));
        }
      });
    // console.log(908765);
      getlist();
     function getlist(){
      //  var templates='<div class="list">hajsdfas</div>';
      //  $(".hotproject").append(templates);
       var aid=$api.getStorage('aid');
       //判断是否为项目经理
       var flag=$api.getStorage('flag');
       //如果是项目经理


       var url='/api/projectPosition/technicaluser/list?aid='+aid+'&page=0&size=10';
      //  console.log(33);
      //  console.log(flag);

       var functionRet=function(ret){
         if (flag==0||flag==1) {
           console.log(1233);
           console.log($api.getStorage('aid'));
           console.log($api.getStorage('flag'));
           var json=ret.list;
           var btn="";
          //  console.log(1244);
           $.each(json, function(commentIndex, comment){
             if(json[commentIndex].isSendCV==false){
               btn='<button  class="btn btn-info sa">申请</button>';
             }else{
               btn='<button class="btn btn-info send">已投递</button>';
             }
            //  console.log(1255);
            //  console.log(json[commentIndex].isSendCV);
            //  console.log(json[commentIndex].positionId);
             var templates='<div class="list"><div class="templatebox"><div class="project_company" isSendCV="'+json[commentIndex].isSendCV+'"  positionId="'+json[commentIndex].positionId+'"><div class="left"><img src="'+json[commentIndex].logo+'" class="company_logo"/></div><div class="left"><div>'+json[commentIndex].businessName+'</div><div class="hot_tags"><span>'+json[commentIndex].keyWord+'</span></div></div>'+'</div><br><div class="project_name"><span>项目名称：</span><span>'+json[commentIndex].projectName+'</span><br><span>实验室名称：</span><span>暂无</span></div><div class="project_detail"><span>地址：</span><span>未知</span><br><span>招募岗位：</span><span>'+json[commentIndex].positionName+'</span><br><span>招募人数：</span><span>'+json[commentIndex].number+'</span><br><span>发布时间：</span><span>'+
                 timestampToTime(json[commentIndex].createTime)+'</span><br>'+btn+'</div></div></div>';

             $(".hotproject").append(templates);
          });

         }
       }
       var functionErr=function(err){
         return false;
       }
       get(url,functionRet,functionErr);

     }
// console.log(1998);
   }

$(function(){
  $(".hotproject").on("click",".list .send",function(e){
    // console.log(100);
    api.alert({
        msg: '您已投递，不可重复投递,请等待公司回复',
    });
  })
})

    $(function(){
      var flag=$api.getStorage('flag');
      // var positionId=$api.grtStorage('positionId');
      var aid=$api.getStorage('aid');
      // console.log(112);
        $(".hotproject").on("click",".list .sa",function(e){
          var button = $(this);
        // console.log(1990);
        var dialogBox = api.require('dialogBox');
        dialogBox.input({
            texts: {
                title: '投递简历',
                placeholder: '输入个人信息',
                leftBtnTitle: '取消',
                rightBtnTitle: '确定'
            },
            styles: {
                bg: '#fff',
                corner: 4,
                h: 200,
                title: {
                    h: 45,
                    alignment: 'center',
                    size: 16,
                    color:'#838c94'
                },
                input: {
                    h: 32,
                    y:50,
                    marginT: 6,
                    textSize: 14,
                    textColor: '#000'
                },
                dividingLine: {
                    width: 0.5,
                    color: '#838c94'
                },
                left: {
                    bg: '#f3f3f3',
                    color: '#838c94',
                    size: 14
                },
                right: {
                    bg: '#37acfe',
                    color: '#fff',
                    size: 14
                }
            }
        }, function(ret,err) {
            if (ret.eventType == 'left') {
                var dialogBox = api.require('dialogBox');
                dialogBox.close({
                    dialogName: 'input'
                });
            }
            if (ret.eventType=='right') {

              var techIntr  = ret.text;
              var url        = '/api/projectPosition';
              //var positionId =$(".project_company").attr("positionId");
              var positionId =button.parent().siblings(":first").attr("positionId");

              // console.log(positionId);
                // console.log($api.getStorage("aid"));
              var data={
                    "aid": $api.getStorage("aid"),
                    "positionId": positionId,
                    "techIntr": techIntr,
                  };
                  // console.log(ret.text);
                  if (ret.text=="") {
                    var dialogBox = api.require('dialogBox');
                    dialogBox.close({
                        dialogName: 'input'
                    });
                    api.alert({
                        msg: '投递失败，请输入信息',
                    });
                  }else {
                    var bb = document.getElementsByClassName('className');
                    // console.log(1996);
                    button.addClass("send");
                    button.html("已投递");
                    // console.log(2000);
                    // console.log(bb);
                    var dialogBox = api.require('dialogBox');
                    dialogBox.close({
                        dialogName: 'input'
                    });

                    var functionRet=function(ret){

                    }
                    var functionErr=function(err){

                    }
                    post(url,data,functionRet,functionErr);
                  }
console.log(10);




                    // console.log(positionId);
            }
            // if (ret.eventType == 'right') {
            //    button.addClass("send");
            //    button.html("已投递");
            //     //一句话介绍自己
            //     var techIntr=ret.text;
            //     var url='/api/projectPosition';
            //     var positionId=button.parent().attr("positionId");
            //     var data={
            //       "aid": $api.getStorage("aid"),
            //       "positionId": positionId,
            //       "techIntr": techIntr
            //     };
            //     var functionRet=function(ret){
            //       api.alert({
            //           msg: '您已成功投递该项目，等待企业回复',
            //       });
            //       var dialogBox = api.require('dialogBox');
            //       dialogBox.close({
            //           dialogName: 'input'
            //       });
            //     }
            //     var functionErr=function(err){
            //       console.log(JSON.stringify(err))
            //       toast("投递失败，请重新投递","bottom");
            //     }
            //     //ajax提交投递简历请求
            //     if(techIntr==""){
            //       api.alert({
            //           msg: '请输入一句话介绍自己',
            //       });
            //     }else{
            //       post(url,data,functionRet,functionErr);
            //     }
            // }
        });

})
    })

</script>

</html>
